<?php

use Illuminate\Database\Seeder;

class CouponSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $data = [
            'name'       => rand(100000,99999999), // 随机生成名称
            'code'       => \App\Model\CouponCode::findAvailableCode(), // 调用优惠码生成方法
            'type'       => rand(1,2),
            'value'      => rand(10,100),
            'total'      => 1000,
            'used'       => 0,
            'min_amount' => rand(100,200),
            'not_before' => null,
            'not_after'  => null,
            'enabled'    => true,
        ];
        for ($i=0;$i<11;$i++) {
            \App\Model\CouponCode::create($data);
        }
    }
}
